import React from 'react'
// ===================================================================== Temp
import TableModal from '#cpt/temp/TableModal'
// ===================================================================== Declare
const { $fn, $http, $Lazy } = window
// ===================================================================== $Lazy
const VersionModal		= $Lazy.state(()=>import('./version-modal'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data: [],
		pag: {},
	}
	
	open = (uuid) => {
		this.uuid = uuid
		this.modal.open()
		this.fetch()
	}
	
	// paging
	fetch = () => $fn.fetch.call(this, 'doc-file-version/index',{param:{uuid:this.uuid}})
	
	// 表单
	cols = [
		{ title: '文件名称', 	dataIndex: 'file_name', 	width:180 },
		{ title: '操作人',		dataIndex: 'real_name', 	...$fn.table.name },
		{ title: '上传时间', 	dataIndex: 'created_at', 	...$fn.table.time },
		{ title: '版本', 		dataIndex: 'version', 		width:80, render: (text,row) => {
			return <span className='c0 cp' onClick={() => {
				$http.submit(null,'doc-file-version/review',{ param:{ version:row.version,file_id:this.uuid},}).then(data=>{
					if($fn.hasArray(data)){
						this.versionRef.open(data[0],row.file_name,row.version)
					}
				})
			}}>第{text}版</span>
		} },
	]
	
	render(){
		return (
			<>
				{TableModal.call(this,{ title: '历史版本', labelWidth:'s7', width:'80%', height:'70%',noSubmit:true,noCancel:true})}
				{/* 历史版本详情 */}
				<VersionModal onRef={ref=>this.versionRef=ref } />
			</>
		)

	}
}

export default Index